package com.example.mytayunapi.Controller;

import com.example.mytayunapi.Entity.product_listInfo;
import com.example.mytayunapi.Service.product_listInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("product_list")
public class product_listController {
    @Autowired
    private product_listInfoService product_list_infoService;

    // 编辑商品分类
    @PutMapping("/update")
    public Integer update(@RequestBody product_listInfo product_listinfo) {
        return product_list_infoService.updateProductList(product_listinfo);
    }

    // 删除商品分类
    @DeleteMapping("/delete/{id}")
    public Integer delete(@PathVariable Integer id) {
        return product_list_infoService.deleteProductList(id);
    }

   // http://localhost:8080/product_list/load
    @GetMapping("/load")
    public List<product_listInfo> getAllProducts() {
        return product_list_infoService.findAll();
    }

    //http://localhost:8080/product_list/insert
    @PostMapping("/insert")
    public Integer insert(@RequestBody product_listInfo product_listinfo){
        return product_list_infoService.insertProduct_list(product_listinfo);
    }


}
